/**
  ******************************************************************************
  * @file    communi_driver.h
  * @author  Sherlock
  * @version V0.1
  * @date    08/30/2024
  * @brief   Outputs Driver
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __COMMUNI_DRIVER_H__
#define  __COMMUNI_DRIVER_H__


#ifdef __cplusplus
 extern "C" {
#endif


/**
  * @brief  INCLUDE FILES.
  */


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   COMMUNI_DRIVER_GLOBALS
#define  COMMUNI_DRIVER_EXT
#else
#define  COMMUNI_DRIVER_EXT  extern
#endif


/*************************************************************************************************
 *                                         定时器
 *************************************************************************************************/
/* Communication Timer */
#define TIM2CountCLK_FREQ                  ((uint32_t) 1800000)   /* HZ */
#define CommuniTIM_RCCPeriph               RCC_APB1_PERIPH_TIM2
#define CommuniTIM_Prescaler               (uint16_t)(SYSMAXCLK_FREQ/TIM2CountCLK_FREQ-1)
#define CommuniTIM_CounterMode             TIM_CNT_MODE_UP
#define CommuniTIM_Period                  35999
#define CommuniTIM_ClockDivision           TIM_CLK_DIV1
#define CommuniTIM_RepetitionCounter       0
#define CommuniTIM                         TIM2
#define CommuniTIM_ITx                     TIM_INT_UPDATE
#define CommuniTIM_FLAGx                   TIM_FLAG_UPDATE
#define CommuniTIM_IRQChannel              TIM2_IRQn
#define CommuniTIM_IRQPrePrio              0x0D
#define CommuniTIM_IRQSubPrio              0x0E

/* USB */
#define USBTIM_IT_CCx                      TIM_INT_CC2
#define USBTIM_FLAG_CCx                    TIM_FLAG_CC2
#define USBTIM_OCMode                      TIM_OCMODE_TIMING     
#define USBTIM_OutputState                 TIM_OUTPUT_STATE_ENABLE
#define USBTIM_OutputNState                TIM_OUTPUT_NSTATE_DISABLE
#define USBTIM_Pulse                       35999                           //30ms
#define USBTIM_OCPolarity                  TIM_OC_POLARITY_LOW 
#define USBTIM_OCNPolarity                 TIM_OCN_POLARITY_LOW 
#define USBTIM_OCIdleState                 TIM_OC_IDLE_STATE_RESET 
#define USBTIM_OCNIdleState                TIM_OCN_IDLE_STATE_RESET


/*************************************************************************************************
 *                                          接口函数
 *************************************************************************************************/
COMMUNI_DRIVER_EXT void COMMUNI_HWInit(void);
COMMUNI_DRIVER_EXT void COMMUNI_HWEnable(void);




#ifdef __cplusplus
}
#endif


#endif   /*  __COMMUNI_DRIVER_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/